**************************************************************************************************
*** This do file creates the replication results for 
*** Spatial Dependence in Asylum Migration	 					 	*/
*** Fabian Barthel (LSE)																			*/
*** Eric Neumayer (LSE)																			*/
*** 																							*/
*** Published in: Journal of Ethnic and Migration Studies, 41 (7), 2015, pp. 1131-1151											*/
**************************************************************************************************
**************************************************************************************************
/* Note: 
You have to change "local DIR" to the directory you copy the original stata files contained 	*/
/* in the zip file and then run the do file. 													*/
**************************************************************************************************

version 12.0
drop _all
clear matrix
clear mata
set mem 800m
set mat 5000

capture net install outreg2, from(http://fmwww.bc.edu/RePEc/bocode/o)			/* checks whether outreg2 is installed 		*/

***********************************************************************************
local DIR = "D:\Research\Development finance\Eric & Fabian\"  /*change relative path to the directory where the files are located */
cd "`DIR'"
***********************************************************************************

use "Article for JEMS (asylum).dta", clear

xtset dyadid year

* Table 1
xi: xtreg ln_asylum_seekers2 ln_refugee_stock_91on   SL_spsc_ID    SL_sptc_hatton_noneg_ID_f SL_sptc_hatton_invnoneg_ID_f cpa_share_filled_zero year#sourceid year#targetid if source!="Czech Republic" & source!="Hungary" & source!="Poland", fe cluster(dyadid)
outreg2 using table1, excel replace

xi: xtreg ln_asylum_seekers2 ln_refugee_stock_91on    SL_spsc_CL_f   SL_sptc_hatton_noneg_ID_f SL_sptc_hatton_invnoneg_ID_f cpa_share_filled_zero year#sourceid year#targetid if source!="Czech Republic" & source!="Hungary" & source!="Poland", fe cluster(dyadid)
outreg2 using table1, excel append

xi: xtreg ln_asylum_seekers2 ln_refugee_stock_91on   SL_spsc_comcol SL_sptc_hatton_noneg_ID_f SL_sptc_hatton_invnoneg_ID_f cpa_share_filled_zero year#sourceid year#targetid if source!="Czech Republic" & source!="Hungary" & source!="Poland", fe cluster(dyadid)
outreg2 using table1, excel append

xi: xtreg ln_asylum_seekers2 ln_refugee_stock_91on   SL_spsc_ID  SL_spsc_CL_f SL_spsc_comcol SL_sptc_hatton_noneg_ID_f SL_sptc_hatton_invnoneg_ID_f cpa_share_filled_zero year#sourceid year#targetid if source!="Czech Republic" & source!="Hungary" & source!="Poland", fe cluster(dyadid)
outreg2 using table1, excel append

* Appendix 1

xtset dyadid year

quietly xi: xtreg ln_asylum_seekers2 ln_refugee_stock_91on   SL_spsc_ID    SL_sptc_hatton_noneg_ID_f SL_sptc_hatton_invnoneg_ID_f cpa_share_filled_zero year#sourceid year#targetid if source!="Czech Republic" & source!="Hungary" & source!="Poland", fe cluster(dyadid)
su year if e(sample)
keep if e(sample)
save sample, replace
collapse (min) year, by(source)


* Appendix 2
use sample, replace
collapse (min) year, by(target)


